home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
rjs.lha
/
RJS
/
String
/
src
/
pad.C
< prev
next >
Wrap
C/C++ Source or Header
|
1991-06-14
|
608b
|
45 lines
#include "String.h"
RJS_String &RJS_String::pad(int len,Side pt,char pc)
{
if (length() >= len) return *this;
RJS_String spc(pc);
int diff=len-length();
switch(pt) {
case Left:
prepend(spc*diff);
break;
case Right:
append(spc*diff);
break;
case Both:
int j=diff/2;
int i=diff-j;
prepend(spc*i);
append(spc*j);
break;
} // switch
return *this;
}
RJS_String pad(const char *s,int len,Side pt,char pc)
{
RJS_String temp(s);
return temp.pad(len,pt,pc);
}
RJS_String pad(const RJS_String &s,int len,Side pt,char pc)
{
RJS_String temp(s);
return temp.pad(len,pt,pc);
}